import { Component, OnInit } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd/message';
import { Router } from '@angular/router';

@Component({
  selector: 'app-portal',
  templateUrl: './portal.component.html',
  styleUrls: ['./portal.component.css']
})
export class PortalComponent implements OnInit {
  // 当前激活的章节索引
  activeChapterIndex = 0;

  // 章节列表数据
  chapterList = [
    { id: 0, title: '第0章', content: '序言', desc: '线性代数的应用场景与学习指南', path: 'preface' },
    { id: 1, title: '第一章', content: '行列式', desc: '行列式的定义、性质与计算方法' , path: 'determinant' },
    { id: 2, title: '第二章', content: '矩阵', desc: '矩阵的概念、运算与初等变换' , path: 'matrix' },
    { id: 3, title: '第三章', content: '向量组', desc: '向量组的线性相关性与秩' , path: 'vector_group' },
    { id: 4, title: '第四章', content: '线性方程式', desc: '线性方程组的求解与解的结构' , path: 'linear_equation' },
    { id: 5, title: '第五章', content: '特征值与特征向量', desc: '特征值、特征向量与矩阵对角化' , path: 'eigenvalue_and_eigenvector' },
    { id: 6, title: '第六章', content: '二次型', desc: '二次型的标准化与正定判断' , path: 'quadratic_form' },
  ];

  constructor(private message: NzMessageService,
              private router: Router,) { }

  ngOnInit(): void { }

  changeChapter(index: number): void {
    this.activeChapterIndex = index;
    // this.message.info(`已切换到「${this.chapterList[index].content}」章节`);
  }

  // 章节跳转方法
  goToChapter(chapter: any): void {
    console.log('跳转至章节：', chapter);
    // 实际项目中可使用路由跳转
    this.router.navigate([chapter.path]).then();
  }
}
